n <- 1000
set.seed(1234)
mac_hole_thickness <- rnorm(n, 486, 142) # generate macular hole inner opening data with mean 486 and sd = 152
logodds_success <- 10.89 - 0.016 * mac_hole_thickness # generate variable that is linear combination of intercept = 10.89 and coefficient for macular hole -0.016 (logit scale)
odds_success <- exp(logodds_success) # exponentiate logodds to get odds
prob_success <- odds_success/(1 + odds_success) # generate probabilities from this
y_success <- rbinom(n, 1, prob_success) # generate outcome variable as a function of those probabilities
df <- data.frame(cbind(mac_hole_thickness,
logodds_success,
prob_success,
y_success))
df <- df |>
filter(mac_hole_thickness > 100) # only include those with thickness > 100